﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using Medianamik.UI.Lock;
using Medianamik.Core;
using Medianamik.Core.Security;

namespace Medianamik.UI.Controls
{
    [ToolboxData("<{0}:DeleteNodeButton runat=server></{0}:DeleteNodeButton>")]
    public class DeleteNodeButton : LockButton
    {
        protected override void OnLoad(EventArgs e)
        {
            Enabled = Enabled && Roles.UserHasRight(NodeId, SecurityLevels.Delete);

            base.OnLoad(e);
        }

        public override string LockedOrDisabledImageUrl
        {
            get
            {
                if (base.LockedOrDisabledImageUrl.Equals(string.Empty))
                    return "/medianamik/images/Icones/Ico_SupprimerInactif.gif";

                return base.LockedOrDisabledImageUrl;
            }
            set
            {
                base.LockedOrDisabledImageUrl = value;
            }
        }

        public override string ImageUrl
        {
            get
            {
                if(base.ImageUrl.Equals(string.Empty))
                    return "/medianamik/images/Icones/Ico_Supprimer.gif";
                return base.ImageUrl;
            }
            set
            {
                base.ImageUrl = value;
            }
        }
    }
}
